package cn.wolfcode.shop.cloud;


import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import java.net.BindException;


public class CommonControllerAdvice {

    //业务异常
    @ExceptionHandler(BusinessException.class)
    @ResponseBody
    public Result handler(BusinessException exception) {
        exception.printStackTrace();
        return Result.error(exception.getCodeMsg());
    }


    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result handlerCommon(Exception ex) {
        ex.printStackTrace();
        return Result.defaultError();
    }
}
